package com.data.service;

import com.data.bean.Account;
import com.data.dbdao.LogindbDao;
import com.data.entity.User;
import com.data.util.CheckDataUtils;
import com.data.util.LoginMethodUtils;
import com.data.util.Md5CodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    @Autowired
    private LogindbDao logindbDao;

    /**
     * 更具账号密码来查找账号信息
     *
     * @param user
     * @return
     */
    public Account loginMethodService(User user) {
        if (CheckDataUtils.stringUtils(user.getPassword())) {
            String parms = LoginMethodUtils.accountType(user.getUsername());
            //加密密码，比较密文
            user.setPassword(Md5CodeUtils.md5(user.getPassword()));
            return logindbDao.loginMethodDao(parms, user.getPassword(), user.getUsername());
        }
        return null;
    }

}
